package com.lixiangfeiyang.recycleritemhelperdemo

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView.Adapter
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.lixiangfeiyang.recycleritemhelperdemo.databinding.AdapterImageBinding
import com.lixiangfeiyang.recycleritemhelperdemo.databinding.AdapterTextBinding


class TextAdapter(var list: ArrayList<Int>) : Adapter<TextAdapter.MyHolder>() {


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyHolder {
        val inflate = AdapterTextBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        return MyHolder(inflate)
    }

    override fun getItemCount(): Int {
        return list.size
    }

    override fun onBindViewHolder(holder: MyHolder, position: Int) {
       holder.textBinding.tv.text = "${list[position]}"
    }


    class MyHolder(var textBinding: AdapterTextBinding) : ViewHolder(textBinding.root) {

    }
}